#pragma once

class ITraceResult;
struct RAY;
enum TraceType;

#include "CRT.h"

class ISpacePartition
{
public:
	virtual ~ISpacePartition() {}
	virtual bool Build() = 0;
	virtual bool IsReady() const = 0;
	virtual void TraceRay(RAY* pRay, TraceType traceType, ITraceResult* pResult) = 0;
};

// of size 12 bytes
struct Vertex
{
	VEC3 position;
};

// see TCRTTriangleHelper in crt.h
// of size 64 bytes
struct Triangle
{
	int meshIndex;
	int vertexIndex[3];
	FPlane plane;
	VEC3 vecPerpToV01;
	float b1;
	VEC3 vecPerpToV02;
	float b2;
};

bool RayIntersectTriangle(const RAY& ray, const Triangle& triangle, float& u, float& v, float& distance);
